package com.example.mobie2032021606170hsy0617homework;


import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql="create table worker("+" _id integer primary key autoincrement,"+"name text not null,"+"skill text not null,"+"money integer)";
        db.execSQL(sql);
        ContentValues values=new ContentValues();
        values.put("name","姓名");
        values.put("skill","技能");
        values.put("money","薪酬");
        db.insert("staff",null,values);
        values.put("name","李刚");
        values.put("skill","汽车工程师");
        values.put("money","200");
        db.insert("staff",null,values);
        values.put("name","丁运生");
        values.put("skill","汽车工人");
        values.put("money","50");
        db.insert("staff",null,values);
        values.put("name","方华高");
        values.put("skill","汽车技术人员");
        values.put("money","300");
        db.insert("staff",null,values);
        values.put("name","王琪");
        values.put("skill","汽车检测人员");
        values.put("money","777");
        db.insert("staff",null,values);
        values.put("name","周丽");
        values.put("skill","汽车厂工人");
        values.put("money","60");
        db.insert("staff",null,values);
        values.put("name","王百年");
        values.put("skill","汽车工程师");
        values.put("money","300");
        db.insert("staff",null,values);
        values.put("name","王莉");
        values.put("skill","汽车厂工人");
        values.put("money","90");
        db.insert("staff",null,values);


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
